/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:
 * Date: 2025-04-02
 * Time: 10:40
 */
public class demo1 {
    public static void main(String[] args) throws InterruptedException {
        Thread t  = new Thread(() -> {
            //这个代码实在 lambda 中（也就是在 t 线程的入口方法中）调用的
            //放回结果就是 t
           while(!Thread.currentThread().isInterrupted()){
               System.out.println("hello thread");
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
           }
        });


        t.interrupt();
        while(true){
            System.out.println("hello main");
            Thread.sleep(1000);
        }
    }
}
